<%@ page contentType="text/html; charset=utf-8" language="java"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="thx" uri="/thx-tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

<style>
	.table-bordered tr{
		text-align: left;
	}
</style>

<section class="content-header">
	<h1>
		流程管理<small>应用流程管理</small>
	</h1>
	<ol class="breadcrumb">
		<li><a href="#"><i class="fa fa-dashboard"></i> 主页</a></li>
		<li><a href="#">应用流程管理</a></li>
		<li class="active">流程管理</li>
	</ol>
</section>

<section class="content">
	<div class="row">
		<div class="col-md-12">
			<div class="box">
				<div class="box-header with-border">
					<div class="row">
						<form class="search-panel" action="workflow/flow!list.action"
							name="search-form" result-container=".content-wrapper">
							<input type="text" name="entity.flowName"
								value="${entity.flowName }" class="form-control"
								placeholder="流程名称">
							<button type="button" class="btn btn-primary search-btn">搜索</button>
						</form>
					</div>
				</div>
				<div class="box-body no-padding">
					<div class="row">
						<div class="col-sm-12">
							<table class="table table-bordered tree">
								<tr>
									<th>流程名称</th>
									<th>创建时间</th>
									<th colspan="2">操作</th>
								</tr>
								<c:if test="${empty list}">
									<tr>
										<td colspan="4" style="text-align: center;">暂无数据！</td>
									</tr>
								</c:if>
								<c:forEach items='${list}' var="flow">
									<tr class="${flow.gridClass }">
					                	<td>${flow.flowName}</td>
					                    <td><fmt:formatDate value="${flow.creatTime }" pattern="yyyy-MM-dd HH:mm:ss"/></td>
					                    <td colspan="2">
					                    	<button type="button"
													title="删除流程"
													data-toggle="tooltip"
													data-placement="bottom"
													do-url="workflow/flow!delete.action?id=${flow.flowId}"
													load-url="workflow/flow!list.action"
													confirm-msg="确定要删除吗？"
													class="btn btn-default btn-sm btn-open-confirm-win">
													<i class="fa fa-trash"></i>
											</button>
					                    </td>
					                </tr>
									<tr class="treegrid-parent-${fn:substring(flow.gridClass, fn:indexOf(flow.gridClass, '-') + 1, fn:length(flow.gridClass))}">
					                	<th>版本号</th>
										<th>创建时间</th>
										<th>状态</th>
										<th min-width="15%">操作</th>
									</tr>
									<c:if test="${empty flow.flowDetails}">
										<tr class="treegrid-parent-${fn:substring(flow.gridClass, fn:indexOf(flow.gridClass, '-') + 1, fn:length(flow.gridClass))}">
											<td colspan="4" style="text-align: center;">暂无数据！</td>
										</tr>
									</c:if>
									<c:forEach items='${flow.flowDetails}' var="detail">
										<tr class="${detail.gridClass }">
											<td>${detail.version}</td>
											<td><fmt:formatDate value="${detail.createTime }" pattern="yyyy-MM-dd HH:mm:ss"/></td>
											<td>
												<c:if test="${detail.state == 0}">
													草稿
												</c:if>
												<c:if test="${detail.state == 1}">
													发布
												</c:if>
											</td>
											<td>
												<a href='${pageContext.request.contextPath}/jbpmService/defineFlow/getFlow?detailId=${detail.detailId}' target="_blank">
													<button type="button"
														title="修改流程"
														data-toggle="tooltip"
														data-placement="bottom"
														class="btn btn-default btn-sm">
														<i class="fa fa-edit"></i>
													</button>
												</a>
												<button type="button"
													title="删除流程"
													data-toggle="tooltip"
													data-placement="bottom"
													do-url="workflow/flow!delDetailFlow.action?detailId=${detail.detailId}"
													load-url="workflow/flow!list.action"
													confirm-msg="确定要删除吗？"
													class="btn btn-default btn-sm btn-open-confirm-win">
													<i class="fa fa-trash"></i>
												</button>
												<c:if test="${detail.state == 0 }">
													<button type="button"
														title="发布流程"
														data-toggle="tooltip"
														data-placement="bottom"
														do-url="workflow/flow!release.action?detailId=${detail.detailId}"
														load-url="workflow/flow!list.action"
														confirm-msg="确定要发布吗？"
														class="btn btn-default btn-sm btn-open-confirm-win">
														<i class="glyphicon glyphicon-share"></i>
													</button>
												</c:if>
												<button type="button" title="复制流程" data-toggle="tooltip"
													data-placement="bottom"
													open-url="workflow/flow!toCopy.action?detailId=${detail.detailId}"
													class="btn btn-default btn-sm btn-open-form">
													<i class="fa fa-copy"></i>
												</button>
											</td>
										</tr>
									</c:forEach>
								</c:forEach>
							</table>
						</div>
					</div>
				</div>
				<div class="box-footer">
					<!--分页区-->
					<div class="pagePanel">
						<thx:pages pageNo="page.curPage" total="page.totalPage" theme="number">
							<s:param name="entity.flowName" value="entity.flowName"></s:param>
						</thx:pages>
					</div>
					<!--底部操作区-->
					<div class="handlePanel">
		                <a title="新增" href="${pageContext.request.contextPath}/jbpmService/defineFlow/getFlow"
							target="_blank"	class="a-btn">
							<span class="fa fa-plus"></span>
							<span class="text">新增</span>
						</a>
					</div>
				</div>
			</div>
		</div>
	</div>
</section>

<script>
	$( function() {
		list.init();
		page.init();
		$(".tree").treegrid();
	});
</script>
